package com.bainuo.doctor.common.image_support.imghandle.picker;

import android.app.Activity;
import android.content.Intent;

import com.bainuo.doctor.common.image_support.MultiImageSelectorActivity;
import com.bainuo.doctor.common.image_support.MultiImageSelector;

import java.util.List;

/**
 * Created by faraway on 14/2/17.
 */
public class MulImagePicker extends BasePicker {

    @Override
    public void pickFromAlbum() {


        if (singleMode) {
            //如果只有一张 使用单选
            MultiImageSelector.create().single().count(maxCount).showCamera(true).start(activity, code);
        } else {
            //使用多张选择
            MultiImageSelector.create().multi().count(maxCount).showCamera(true).start(activity, code);
        }
    }

    @Override
    public void pickFromCamera() {

    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {

        //从回调中获取数据
        if (requestCode == code && resultCode == Activity.RESULT_OK) {
            List<String> paths = data.getStringArrayListExtra(MultiImageSelectorActivity.EXTRA_RESULT);
            listener.onPictureSelected(null, paths);
        }
    }

}
